const Router = require("koa-router");
const {Flow} = require('../../models/flow')
const {Art} = require('../../models/art')
const router = new Router({
    prefix:'/v1/classic'
});

const {PositiveIntegerValidator} = require('../../validator/validator')
// const {User} = require('../../models/user')
const {Auth} = require('../../../middleware/auth')

// new Auth().m 接口token权限验证
router.get("/latest",new Auth().m,async (ctx, next) => {
    // 参数校验
    // const v = new PositiveIntegerValidator().validate(ctx)
    // const id = v.get('path.id',parsed=true)
    // ctx.body = id
    const flow = await Flow.findOne({
        attributes:['id','index','art_id','type','created_at'],
        order:[
            ['index','DESC']
        ],
       
    })
    console.log(flow,"++++++++++++++++++++++++++");
    const art = await Art.getData(flow.dataValues.art_id,flow.dataValues.type)
    console.log(art,"artsssssssssssssssssssssss");
    art.setDataValue('index',flow.index)
    ctx.body = art

});



module.exports = router;
